package com.spark.tags;

import java.util.Map;

import com.spark.core.SparkContext;


public class DateTimePicker extends DatePicker {

	private static final String DEFAULT_TEMPLATES = "dateTimePicker.ftl";

	public String getTemplate() {
		return DEFAULT_TEMPLATES;
	}
	
	
	@SuppressWarnings("unchecked")
	protected String build(SparkContext context){
		Map map = context.getMap();
		StringBuilder sb = new StringBuilder();
		sb.append("<div class=\"").append(get(map,"className")).append("\" style=\"width:").append(get(map,"width")).append("px;").append(get(map,"style")).append("\" id=\"").append(get(map,"id")).append("\">\r");
		sb.append("    <input class=\"s_tf\" stype=\"input\" style=\"width: ").append(get(map,"inputWidth")).append("px;\" ").append(get(map,"readOnly")).append(" autocomplete=\"off\" value=\"").append(get(map,"value")).append("\" />\r");
		sb.append("    <div class=\"s_tg s_dbtn\" stype=\"trigger\" hidefocus></div>\r");
		sb.append("    <div class=\"s_popup\" stype=\"popup\">\r");
		sb.append("        <table>\r");
		sb.append("            <tr>\r");
		sb.append("                ").append(get(map,"body"));
		sb.append("            </tr>\r");
		sb.append("        </table>\r");
		sb.append("        <div class=\"s_dp_foot\" align=\"center\">\r");
		sb.append("            <div class=\"s_dp_input\" style=\"width:66px !important;width:61px;\">\r");
		sb.append("                <input style=\"width:14px\" maxlength=\"2\" stype=\"field.hour\">\r");
		sb.append("                <div style=\"width:8px\">:</div>\r");
		sb.append("                <input style=\"width:14px\" maxlength=\"2\" stype=\"field.minute\">\r");
		sb.append("                <div style=\"width:8px\">:</div>\r");
		sb.append("                <input style=\"width:14px\" maxlength=\"2\" stype=\"field.second\">\r");
		sb.append("            </div>\r");
		sb.append("        </div>\r");
		sb.append("    </div>\r");
		sb.append("</DIV>\r");
		sb.append("<script>new Spark.DateTimePicker(").append(get(map,"config")).append(");</script>\r");
		sb.append("\r");
		sb.append("\r");
		return sb.toString();
	}
}
